package com.fortune.service.impl;

import com.fortune.dao.ChannelDiscountMgtDao;
import com.fortune.dto.in.channelDiscount.ChannelDiscountAddDto;
import com.fortune.dto.in.channelDiscount.ChannelDiscountEditDto;
import com.fortune.dto.in.channelDiscount.ChannelDiscountListDto;
import com.fortune.service.ChannelDiscountMgtService;
import com.fortune.vo.channelDiscountMgt.ChannelDiscount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ChannelDiscountMgtServiceImpl implements ChannelDiscountMgtService {
    @Autowired
    private ChannelDiscountMgtDao channelDiscountMgtDao;

    /**
     * 优惠政策列表
     * @param companyId
     * @param channelDiscountListDto
     * @return
     */
    @Override
    public List<ChannelDiscount> queryChannelDiscountList(String companyId, ChannelDiscountListDto channelDiscountListDto) {
        return channelDiscountMgtDao.queryChannelDiscountList(companyId,channelDiscountListDto);
        }

    /**
     * 优惠政策列表数量
     * @param companyId
     * @param channelDiscountListDto
     * @return
     */
    @Override
    public int queryChannelDiscountListCount(String companyId, ChannelDiscountListDto channelDiscountListDto) {
        return channelDiscountMgtDao.queryChannelDiscountListCount(companyId,channelDiscountListDto);
    }

    /**
     * 根据优惠名称查找数据是否存在
     * @param companyId
     * @param name
     * @return
     */
    @Override
    public int queryChannelDiscountCountByName(String companyId, String name) {
        return channelDiscountMgtDao.queryChannelDiscountCountByName(companyId,name);
    }

    @Override
    public int findTime(String mid, String proId, Date startTime, Date endTime) {
        return channelDiscountMgtDao.findTime(mid,proId,startTime,endTime);
    }

    @Override
    public int findTimes(String mid, String proId, Date startTime, Date endTime,String id) {
        return channelDiscountMgtDao.findTimes(mid,proId,startTime,endTime,id);
    }
    /**
     * 添加优惠政策
     * @param companyId
     * @param addDto
     * @return
     */
    @Override
    public int addChannelDiscountCount(String companyId, ChannelDiscountAddDto addDto) {
        return channelDiscountMgtDao.addChannelDiscountCount(companyId,addDto);
    }

    @Override
    public int deleteChannelDiscountCount(String companyId, String channelDiscountId) {
        return channelDiscountMgtDao.deleteChannelDiscountCount(companyId,channelDiscountId);
    }

    /**
     * 编辑时查看是否存在
     * @param companyId
     * @param editDto
     * @return
     */
    @Override
    public int queryIsExist(String companyId, ChannelDiscountEditDto editDto) {
        return channelDiscountMgtDao.queryIsExist(companyId,editDto);
    }

    /**
     * 编辑优惠政策
     * @param companyId
     * @param editDto
     * @return
     */
    @Override
    public int editChannelDiscountCount(String companyId, ChannelDiscountEditDto editDto) {
        return channelDiscountMgtDao.editChannelDiscountCount(companyId,editDto);
    }
}
